package com.ihg.hiex.admin.service.session.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.demo2do.core.persistence.GenericDaoSupport;
import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.utils.CollectionUtils;
import com.ihg.hiex.admin.dao.session.SessionAnchorDao;
import com.ihg.hiex.admin.dao.session.SessionCalibrationDao;
import com.ihg.hiex.admin.dao.session.SessionCompetencyDao;
import com.ihg.hiex.admin.dao.session.SessionExerciseDao;
import com.ihg.hiex.admin.dao.session.SessionExerciseReflectionDao;
import com.ihg.hiex.admin.dao.session.SessionInbasketDao;
import com.ihg.hiex.admin.dao.session.SessionMeetingDao;
import com.ihg.hiex.admin.dao.session.SessionReportDao;
import com.ihg.hiex.admin.dao.session.SessionReportWritingDao;
import com.ihg.hiex.admin.dao.session.SessionTaskDao;
import com.ihg.hiex.admin.entity.security.Login;
import com.ihg.hiex.admin.service.session.SessionDuringService;
import com.ihg.hiex.entity.session.Session;
import com.ihg.hiex.entity.session.after.SessionReport;
import com.ihg.hiex.entity.session.during.SessionAnchorScore;
import com.ihg.hiex.entity.session.during.SessionAnchorScoreType;
import com.ihg.hiex.entity.session.during.SessionCalibration;
import com.ihg.hiex.entity.session.during.SessionCalibrationAnchorScore;
import com.ihg.hiex.entity.session.during.SessionCalibrationComment;
import com.ihg.hiex.entity.session.during.SessionCalibrationCompetency;
import com.ihg.hiex.entity.session.during.SessionCalibrationRecommendation;
import com.ihg.hiex.entity.session.during.SessionCalibrationStatus;
import com.ihg.hiex.entity.session.during.SessionCompetencyScore;
import com.ihg.hiex.entity.session.during.SessionExercise;
import com.ihg.hiex.entity.session.during.SessionExerciseReflection;
import com.ihg.hiex.entity.session.during.SessionInBasket;
import com.ihg.hiex.entity.session.during.SessionInBasketAnswer;
import com.ihg.hiex.entity.session.during.SessionInBasketAnswerStatus;
import com.ihg.hiex.entity.session.during.report.SessionReportComment;
import com.ihg.hiex.entity.session.during.report.SessionReportRecommendation;
import com.ihg.hiex.entity.session.during.report.SessionReportWriting;
import com.ihg.hiex.entity.session.meeting.SessionMeeting;
import com.ihg.hiex.entity.session.participator.Type;
import com.ihg.hiex.entity.session.task.SessionTask;
import com.ihg.hiex.entity.session.task.Status;
import com.ihg.hiex.entity.user.Assessor;
import com.ihg.hiex.entity.user.Delegate;
import com.ihg.hiex.entity.user.Role;

/**
 * 
 * @author dan
 *
 */
@Service("sessionDuringService")
public class SessionDuringServiceImpl implements SessionDuringService{
    
    @Dao
    private SessionExerciseDao sessionExerciseDao;
    
    @Dao
    private SessionCompetencyDao sessionCompetencyDao;
    
    @Dao
    private SessionAnchorDao sessionAnchorDao;
    
    @Autowired
    private GenericDaoSupport genericDaoSupport;
    
    @Dao
    private SessionMeetingDao sessionMeetingDao;
    
    @Dao
    private SessionExerciseReflectionDao sessionExerciseReflectionDao;
    
    @Dao
    private SessionTaskDao sessionTaskDao;
    
    @Dao
    private SessionInbasketDao sessionInbasketDao;
    
    @Dao
    private SessionCalibrationDao sessionCalibrationDao;
    
    @Dao
    private SessionReportDao sessionReportDao;
    
    @Dao
    private SessionReportWritingDao sessionReportWritingDao;
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#listSessionAnchorScore(com.ihg.hiex.entity.session.during.SessionCompetencyScore)
     */
    public List<SessionAnchorScore> listSessionAnchorScore(SessionCompetencyScore sessionCompetencyScore) {
        return sessionAnchorDao.list(sessionCompetencyScore);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.admin.service.SessionDuringService#listSessionAnchorScore(java.util.List)
     */
    public List<SessionAnchorScore> listSessionAnchorScore(List<SessionCompetencyScore> sessionCompetencyScores) {
        return sessionAnchorDao.list(sessionCompetencyScores);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#listSessionInBasketAnswer(com.ihg.hiex.entity.session.during.SessionInBasket, java.lang.String)
     */
    public Map<String, List<SessionInBasketAnswer>> listSessionInBasketAnswer(SessionInBasket sessionInBasket, String name) {
        List<SessionInBasketAnswer> answers = sessionInbasketDao.listAnswer(sessionInBasket, name);
        return CollectionUtils.constructMapValues(answers, "type.alias");
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#listSessionInBasketAnswer(com.ihg.hiex.entity.session.during.SessionInBasket)
     */
    public Map<String, Map<String, List<SessionInBasketAnswer>>> listSessionInBasketAnswer(SessionInBasket sessionInBasket) {
        List<SessionInBasketAnswer> answers = sessionInbasketDao.listAnswer(sessionInBasket);
        
        Map<String, List<SessionInBasketAnswer>> answer = CollectionUtils.constructMapValues(answers, "name");
        Map<String, Map<String, List<SessionInBasketAnswer>>> result = new HashMap<String, Map<String, List<SessionInBasketAnswer>>>();
        for(Entry<String, List<SessionInBasketAnswer>> answerItem : answer.entrySet()) {
            Map<String, List<SessionInBasketAnswer>> resultItem = CollectionUtils.constructMapValues(answerItem.getValue(), "type.alias");
            result.put(answerItem.getKey(), resultItem);
        }
        
        return result;
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.admin.service.session.SessionDuringService#listSessionInBasketAnswer(java.util.List)
     */
    public Map<String, List<SessionInBasketAnswer>> listSessionInBasketAnswer(List<SessionInBasket> sessionInBaskets) {
        List<SessionInBasketAnswer> answers = sessionInbasketDao.listAnswer(sessionInBaskets);
        return CollectionUtils.constructMapValues(answers, "sessionInBasket.delegate.id");
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#listSessionCalibration(com.ihg.hiex.entity.session.Session, java.util.List)
     */
    public List<SessionCalibration> listSessionCalibration(Session session, List<Long> delegateIds) {
        return sessionCalibrationDao.listCalibration(session, delegateIds);
    }
    
    /* (non-Javadoc)
     * @see com.ihg.hiex.admin.service.SessionDuringService#listSessionExercise(com.ihg.hiex.entity.session.Session, com.ihg.hiex.entity.user.Delegate, java.util.List)
     */
    public Map<String, SessionExercise> listSessionExercise(Session session, Delegate delegate, List<String> names) {
        List<SessionExercise> exercises = sessionExerciseDao.list(session, delegate, names);
        return CollectionUtils.constructMapValue(exercises, "name");
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#listSessionCalibrationCompetency(java.util.List)
     */
    public Map<String, Map<String, SessionCalibrationCompetency>> listSessionCalibrationCompetency(List<SessionCalibration> sessionCalibrations) {
        List<SessionCalibrationCompetency> sessionCalibrationCompetencies = sessionCalibrationDao.listCompetency(sessionCalibrations);
        Map<String, List<SessionCalibrationCompetency>> competencies = CollectionUtils.constructMapValues(sessionCalibrationCompetencies, "sessionCalibration.id");
        
        Map<String, Map<String, SessionCalibrationCompetency>> result = new HashMap<String, Map<String, SessionCalibrationCompetency>>();
        for(Entry<String, List<SessionCalibrationCompetency>> competency : competencies.entrySet()) {
            Map<String, SessionCalibrationCompetency> resultItem = CollectionUtils.constructMapValue(competency.getValue(), "name");
            result.put(competency.getKey(), resultItem);
        }
        
        return result;
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#listSessionCalibrationCompetency(com.ihg.hiex.entity.session.during.SessionCalibration)
     */
    public List<SessionCalibrationCompetency> listSessionCalibrationCompetency(SessionCalibration sessionCalibration) {
        return sessionCalibrationDao.listCompetency(sessionCalibration);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.admin.service.SessionDuringService#listSessionCalibrationAnchorScore(java.util.List)
     */
    public Map<String, Map<String, List<SessionCalibrationAnchorScore>>> listSessionCalibrationAnchorScore(List<SessionCalibrationCompetency> competencies) {
        List<SessionCalibrationAnchorScore> anchorScores = sessionCalibrationDao.listAnchorScore(competencies);
        Map<String, List<SessionCalibrationAnchorScore>> anchorScore = CollectionUtils.constructMapValues(anchorScores, "competency.name");
        
        Map<String, Map<String, List<SessionCalibrationAnchorScore>>> result = new HashMap<String, Map<String, List<SessionCalibrationAnchorScore>>>();
        for(Entry<String, List<SessionCalibrationAnchorScore>> score : anchorScore.entrySet()) {
            Map<String, List<SessionCalibrationAnchorScore>> resultItem = new HashMap<String, List<SessionCalibrationAnchorScore>>();
            
            List<SessionCalibrationAnchorScore> strongScore = new ArrayList<SessionCalibrationAnchorScore>();
            List<SessionCalibrationAnchorScore> weakScore = new ArrayList<SessionCalibrationAnchorScore>();
            for(SessionCalibrationAnchorScore calibrationAnchorScore : score.getValue()) {
                if(calibrationAnchorScore.isStrong()) {
                    strongScore.add(calibrationAnchorScore);
                } else if (calibrationAnchorScore.isWeak()) {
                    weakScore.add(calibrationAnchorScore);
                }
            }
            resultItem.put("strong", strongScore);
            resultItem.put("weak", weakScore);
            result.put(score.getKey(), resultItem);
        }
        return result;
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.admin.service.SessionDuringService#listSessionCalibrationAnchorScores(java.util.List, boolean)
     */
    public Map<String, List<SessionCalibrationAnchorScore>> listSessionCalibrationAnchorScores(List<SessionCalibrationCompetency> competencies, boolean strong) {
        
        List<SessionCalibrationAnchorScore> anchorScores = new ArrayList<SessionCalibrationAnchorScore>();
        if(strong) {
            anchorScores = sessionCalibrationDao.listStrongAnchorScores(competencies);
        } else {
            anchorScores = sessionCalibrationDao.listWeakAnchorScores(competencies);
        }
        Map<String, List<SessionCalibrationAnchorScore>> anchorScore = CollectionUtils.constructMapValues(anchorScores, "competency.name");
        return anchorScore;
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#listSessionCalibrationComment(java.util.List)
     */
    public Map<String, SessionCalibrationComment> listSessionCalibrationComment(
            List<SessionCalibration> sessionCalibrations) {
        List<SessionCalibrationComment> sessionCalibrationComments = sessionCalibrationDao.listComment(sessionCalibrations);
        return CollectionUtils.constructMapValue(sessionCalibrationComments, "sessionCalibration.id");
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#listCalibrationAnchorScore(com.ihg.hiex.entity.session.during.SessionCalibrationCompetency)
     */
    public List<SessionCalibrationAnchorScore> listCalibrationAnchorScore(
            SessionCalibrationCompetency sessionCalibrationCompetency) {
        return sessionCalibrationDao.listAnchorScore(sessionCalibrationCompetency);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#listMeetingAnchorScore(com.ihg.hiex.entity.session.Session, com.ihg.hiex.entity.user.Assessor[], com.ihg.hiex.entity.user.Delegate, java.lang.String)
     */
    public Map<String, Map<String, Map<String, SessionAnchorScore>>> listMeetingAnchorScore(Session session, Assessor[] assessors, Delegate delegate, String competencyName) {
        List<SessionAnchorScore> anchorScores = sessionAnchorDao.listMeetingScore(session, assessors, delegate, competencyName);
        Map<String, List<SessionAnchorScore>> anchorScore = CollectionUtils.constructMapValues(anchorScores, "sessionAnchor.code");
        
        Map<String, Map<String, Map<String, SessionAnchorScore>>> result = new HashMap<String, Map<String, Map<String, SessionAnchorScore>>>();
        for(Entry<String, List<SessionAnchorScore>> score : anchorScore.entrySet()) {
            Map<String, Map<String, SessionAnchorScore>> scores = new HashMap<String, Map<String, SessionAnchorScore>>();
            Map<String, List<SessionAnchorScore>> assessorScore = CollectionUtils.constructMapValues(score.getValue(), "sessionCompetencyScore.sessionExercise.assessor.id");
            for(Entry<String, List<SessionAnchorScore>> scoreItem : assessorScore.entrySet()) {
                Map<String, SessionAnchorScore> meetingScore = CollectionUtils.constructMapValue(scoreItem.getValue(), "sessionAnchor.meetingName");
                scores.put(scoreItem.getKey(), meetingScore);
            }
            result.put(score.getKey(), scores);
        }
        
        return result;
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.admin.service.session.SessionDuringService#listMeetingAnchorScores(com.ihg.hiex.entity.session.Session, com.ihg.hiex.entity.user.Delegate, java.lang.String)
     */
    public Map<String, List<SessionAnchorScore>> listMeetingAnchorScores(Session session, Delegate delegate,
            String competencyName) {
        List<SessionAnchorScore> scores = sessionAnchorDao.listMeetingScore(session, delegate, competencyName);
        
        return CollectionUtils.constructMapValues(scores, "sessionCompetencyScore.sessionCompetency.meetingName");
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#listMeetingAnchorScores(com.ihg.hiex.entity.session.Session, com.ihg.hiex.entity.user.Assessor[], com.ihg.hiex.entity.user.Delegate, java.lang.String)
     */
    public Map<String, List<SessionAnchorScore>> listMeetingAnchorScores(Session session, Assessor[] assessors,
            Delegate delegate, String competencyName) {
        List<SessionAnchorScore> anchorScores = sessionAnchorDao.listMeetingScore(session, assessors, delegate, competencyName);
        return CollectionUtils.constructMapValues(anchorScores, "sessionAnchor.code");
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.admin.service.session.SessionDuringService#listMeetingAnchorScore(com.ihg.hiex.entity.session.Session, java.lang.String)
     */
    public Map<String, Map<String, SessionAnchorScore>> listMeetingAnchorScore(Session session, String meetingName) {
        List<SessionAnchorScore> scores = sessionAnchorDao.listMeetingScore(session, meetingName);
        Map<String, List<SessionAnchorScore>> delegateScores = CollectionUtils.constructMapValues(scores, "sessionCompetencyScore.sessionExercise.delegate.id");
        
        Map<String, Map<String, SessionAnchorScore>> result = new HashMap<String, Map<String, SessionAnchorScore>>();
        for(Entry<String, List<SessionAnchorScore>> delegateScore : delegateScores.entrySet()) {
            Map<String, SessionAnchorScore> resultItem = CollectionUtils.constructMapValue(delegateScore.getValue(), "sessionAnchor.code");
            result.put(delegateScore.getKey(), resultItem);
        }
        return result;
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.admin.service.session.SessionDuringService#listInBasketAnchorScore(com.ihg.hiex.entity.session.Session, com.ihg.hiex.entity.user.Delegate, java.lang.String)
     */
    public List<SessionAnchorScore> listInBasketAnchorScore(Session session, Delegate delegate,
            String competencyName) {
        return sessionAnchorDao.listInBasketScore(session, delegate, competencyName);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#listInBasketAnchorScore(com.ihg.hiex.entity.session.Session, com.ihg.hiex.entity.user.Assessor[], com.ihg.hiex.entity.user.Delegate, java.lang.String)
     */
    public Map<String, Map<String, SessionAnchorScore>> listInBasketAnchorScore(Session session, Assessor[] assessors, Delegate delegate, String competencyName) {
        List<SessionAnchorScore> anchorScores = sessionAnchorDao.listInBasketScore(session, assessors, delegate, competencyName);
        Map<String, List<SessionAnchorScore>> anchorScore = CollectionUtils.constructMapValues(anchorScores, "sessionAnchor.code");
        
        Map<String, Map<String, SessionAnchorScore>> result = new HashMap<String, Map<String, SessionAnchorScore>>();
        for(Entry<String, List<SessionAnchorScore>> score : anchorScore.entrySet()) {
            Map<String, SessionAnchorScore> assessorScore = CollectionUtils.constructMapValue(score.getValue(), "sessionCompetencyScore.sessionInBasket.assessor.id");
            result.put(score.getKey(), assessorScore);
        }
        
        return result;
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#listInBasketAnchorScores(com.ihg.hiex.entity.session.Session, com.ihg.hiex.entity.user.Assessor[], com.ihg.hiex.entity.user.Delegate, java.lang.String)
     */
    public Map<String, List<SessionAnchorScore>> listInBasketAnchorScores(Session session, Assessor[] assessors,
            Delegate delegate, String competencyName) {
        List<SessionAnchorScore> anchorScores = sessionAnchorDao.listInBasketScore(session, assessors, delegate, competencyName);
        return CollectionUtils.constructMapValues(anchorScores, "sessionAnchor.code");
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.admin.service.session.SessionDuringService#listInBasketAnchorScore(com.ihg.hiex.entity.session.Session)
     */
    public Map<String, Map<String, SessionAnchorScore>> listInBasketAnchorScore(Session session) {
        List<SessionAnchorScore> scores = sessionAnchorDao.listInBasketScore(session);
        Map<String, List<SessionAnchorScore>> delegateScores = CollectionUtils.constructMapValues(scores, "sessionCompetencyScore.sessionInBasket.delegate.id");
        
        Map<String, Map<String, SessionAnchorScore>> result = new HashMap<String, Map<String, SessionAnchorScore>>();
        for(Entry<String, List<SessionAnchorScore>> delegateScore : delegateScores.entrySet()) {
            Map<String, SessionAnchorScore> resultItem = CollectionUtils.constructMapValue(delegateScore.getValue(), "sessionAnchor.code");
            result.put(delegateScore.getKey(), resultItem);
        }
        return result;
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.admin.service.SessionDuringService#listSessionExercise(com.ihg.hiex.entity.session.Session)
     */
    public List<SessionExercise> listSessionExercise(Session session) {
        return sessionExerciseDao.list(session);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#listSessionCompetencyScore(com.ihg.hiex.entity.session.Session, com.ihg.hiex.entity.user.Delegate)
     */
    public Map<String, List<SessionCompetencyScore>> listSessionCompetencyScore(Session session, Delegate delegate) {
        // list delegate's sessionexercise and sessioninbasket
        List<SessionExercise> sessionExercises = sessionExerciseDao.list(session, delegate);
        SessionInBasket sessionInBasket = sessionInbasketDao.load(session, delegate);
        
        List<SessionCompetencyScore> sessionCompetencyScores = sessionCompetencyDao.list(sessionExercises, sessionInBasket);
        return CollectionUtils.constructMapValues(sessionCompetencyScores, "sessionCompetency.meetingName");
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.admin.service.SessionDuringService#listSessionCompetencyScore(java.util.List)
     */
    public List<SessionCompetencyScore> listSessionCompetencyScore(List<SessionExercise> sessionExercises) {
        
        return null;
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#listSessionCompetencyScore(java.lang.String[], com.ihg.hiex.entity.session.Session, com.ihg.hiex.entity.user.Delegate)
     */
    public Map<String, SessionCompetencyScore> listSessionCompetencyScore(String[] competencyNames, Session session, Delegate delegate) {
        
        // list delegate's sessionexercise and sessioninbasket
        List<SessionExercise> sessionExercises = sessionExerciseDao.list(session, delegate);
        SessionInBasket sessionInBasket = sessionInbasketDao.load(session, delegate);
        
        List<SessionCompetencyScore> sessionCompetencyScores = sessionCompetencyDao.list(sessionExercises, sessionInBasket, competencyNames);
        return CollectionUtils.constructMapValue(sessionCompetencyScores, "sessionCompetency.meetingName");
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.admin.service.SessionDuringService#listSessionCalibrationRecommendation(java.util.List)
     */
    public Map<String, SessionCalibrationRecommendation> listSessionCalibrationRecommendation(
            List<SessionCalibration> sessionCalibrations) {
        List<SessionCalibrationRecommendation> sessionCalibrationRecommendations = sessionCalibrationDao.listRecommendation(sessionCalibrations);
        return CollectionUtils.constructMapValue(sessionCalibrationRecommendations, "sessionCalibration.id");
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.admin.service.SessionDuringService#loadSessionCalibrationRecommendation(com.ihg.hiex.entity.session.during.SessionCalibration)
     */
    public SessionCalibrationRecommendation loadSessionCalibrationRecommendation(
            SessionCalibration sessionCalibration) {
        return sessionCalibrationDao.loadRecommendation(sessionCalibration);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#loadSessionExercise(com.ihg.hiex.entity.session.Session, com.ihg.hiex.entity.user.Assessor, com.ihg.hiex.entity.user.Delegate, java.lang.String)
     */
    public SessionExercise loadSessionExercise(Session session, Assessor assessor, Delegate delegate, String name) {
        return sessionExerciseDao.load(session, assessor, delegate, name);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#loadSessionExercise(java.lang.Long)
     */
    public SessionExercise loadSessionExercise(Long exerciseId) {
        return genericDaoSupport.load(SessionExercise.class, exerciseId);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.admin.service.session.SessionDuringService#listSessionInbasket(com.ihg.hiex.entity.session.Session, java.lang.String)
     */
    public List<SessionInBasket> listSessionInbasket(Session session, String name) {
        return sessionInbasketDao.list(session, name);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#loadSessionInbasket(com.ihg.hiex.entity.session.Session, com.ihg.hiex.entity.user.Assessor, com.ihg.hiex.entity.user.Delegate, java.lang.String)
     */
    public SessionInBasket loadSessionInbasket(Session session, Assessor assessor, Delegate delegate, String name) {
        return sessionInbasketDao.load(session, assessor, delegate, name);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#loadSessionInbasket(java.lang.Long)
     */
    public SessionInBasket loadSessionInbasket(Long sessionInbasketId) {
        return genericDaoSupport.load(SessionInBasket.class, sessionInbasketId);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.admin.service.session.SessionDuringService#loadSessionInbasket(com.ihg.hiex.entity.session.Session, com.ihg.hiex.entity.user.Delegate)
     */
    public SessionInBasket loadSessionInbasket(Session session, Delegate delegate) {
        return sessionInbasketDao.load(session, delegate);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#loadSessionCompetencyScore(com.ihg.hiex.entity.session.during.SessionExercise, java.lang.String)
     */
    public SessionCompetencyScore loadSessionCompetencyScore(SessionExercise sessionExercise, String competencyName) {
        return sessionCompetencyDao.load(sessionExercise, competencyName);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#loadSessionCompetencyScore(com.ihg.hiex.entity.session.during.SessionInBasket, java.lang.String)
     */
    public SessionCompetencyScore loadSessionCompetencyScore(SessionInBasket sessionInBasket, String competencyName) {
        return sessionCompetencyDao.load(sessionInBasket, competencyName);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#loadSessionCompetencyScore(java.lang.Long)
     */
    public SessionCompetencyScore loadSessionCompetencyScore(Long competencyId) {
        return genericDaoSupport.load(SessionCompetencyScore.class, competencyId);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#loadSessionCompetencyScore(com.ihg.hiex.entity.session.during.SessionExercise)
     */
    public SessionCompetencyScore loadSessionCompetencyScore(SessionExercise sessionExercise) {
        return sessionCompetencyDao.load(sessionExercise, false);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#loadSessionInBasket(com.ihg.hiex.entity.session.Session, com.ihg.hiex.entity.user.Delegate)
     */
    public SessionInBasket loadSessionInBasket(Session session, Delegate delegate) {
        return sessionInbasketDao.load(session, delegate);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#loadSessionCalibration(java.lang.Long)
     */
    public SessionCalibration loadSessionCalibration(Long calibrationId) {
        return genericDaoSupport.load(SessionCalibration.class, calibrationId);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#loadSessionCalibration(com.ihg.hiex.entity.session.Session, com.ihg.hiex.entity.user.Delegate)
     */
    public SessionCalibration loadSessionCalibration(Session session, Delegate delegate) {
        return sessionCalibrationDao.loadCalibration(session, delegate);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#loadSessionCalibrationCompetency(com.ihg.hiex.entity.session.during.SessionCalibration, java.lang.String)
     */
    public SessionCalibrationCompetency loadSessionCalibrationCompetency(SessionCalibration sessionCalibration,
            String name) {
        return sessionCalibrationDao.loadCompetency(sessionCalibration, name);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#loadSessionCalibrationCompetency(java.lang.Long)
     */
    public SessionCalibrationCompetency loadSessionCalibrationCompetency(Long competencyId) {
        return genericDaoSupport.load(SessionCalibrationCompetency.class, competencyId);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#loadSessionReport(com.ihg.hiex.entity.session.Session, com.ihg.hiex.entity.user.Delegate)
     */
    public SessionReport loadSessionReport(Session session, Delegate delegate) {
        return sessionReportDao.load(session, delegate);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#countFinishCompetencyScore(com.ihg.hiex.entity.session.during.SessionExercise)
     */
    public int countFinishCompetencyScore(SessionExercise sessionExercise) {
        return sessionCompetencyDao.count(sessionExercise, true);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#countFinishCompetencyScore(com.ihg.hiex.entity.session.during.SessionInBasket)
     */
    public int countFinishCompetencyScore(SessionInBasket sessionInBasket) {
        return sessionCompetencyDao.count(sessionInBasket, true);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#loadSessionMeeting(com.ihg.hiex.entity.session.Session, java.lang.String, java.lang.Long, java.lang.Long)
     */
    public SessionMeeting loadSessionMeeting(Session session, String name, Long owner, Long delegate) {
        return sessionMeetingDao.load(session, name, owner, delegate);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#score(com.ihg.hiex.entity.session.during.SessionCompetencyScore, java.lang.String, java.lang.String, java.util.List)
     */
    public void score(SessionCompetencyScore competencyScore, String effective, String inEffective,
            List<String> anchorScores) {
        // update sessionCompetencyScore first
        genericDaoSupport.update(competencyScore.score(effective, inEffective));
        
        // update sessionAnchorScore one by one 
        for(String anchorScore : anchorScores) {
            String[] datas = StringUtils.split(anchorScore, "|");
            Long anchorScoreId = Long.parseLong(datas[0]);
            String score = datas[1];
            
            // get sessionAnchorScore
            SessionAnchorScore sessionAnchorScore = genericDaoSupport.load(SessionAnchorScore.class, anchorScoreId);
            genericDaoSupport.update(sessionAnchorScore.score(SessionAnchorScoreType.aliasOf(score)));
        }
        
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#summary(com.ihg.hiex.entity.session.during.SessionExercise)
     */
    public void summary(SessionExercise sessionExercise) {
        genericDaoSupport.update(sessionExercise);
    }

    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#loadExerciseReflection(com.ihg.hiex.entity.session.during.SessionExercise)
     */
    public SessionExerciseReflection loadExerciseReflection(SessionExercise sessionExercise) {
        return sessionExerciseReflectionDao.load(sessionExercise);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#loadSessionCalibrationComment(com.ihg.hiex.entity.session.during.SessionCalibration)
     */
    public SessionCalibrationComment loadSessionCalibrationComment(SessionCalibration sessionCalibration) {
        return sessionCalibrationDao.loadComment(sessionCalibration);
    }

    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#saveAndFinish(com.ihg.hiex.entity.session.during.SessionExercise, com.ihg.hiex.entity.user.Delegate, com.ihg.hiex.entity.session.during.SessionExerciseReflection, com.ihg.hiex.entity.session.task.SessionTask)
     */
    public void selfReflection(SessionExercise sessionExercise, Delegate delegate, SessionExerciseReflection sessionExerciseReflection, SessionTask sessionTask) {
        
        // 1. save sessionExerciseReflection
        genericDaoSupport.save(sessionExerciseReflection.bind(sessionExercise, delegate));
        
        // 2. finish sessionTask
        genericDaoSupport.update(sessionTask.status(Status.FINISH));
        
        // 3. if sessionTask's bother finish update parent 
        List<SessionTask> sessionTasks = sessionTaskDao.list(sessionTask.getSession(), sessionTask.getAssessor(), sessionTask.getDelegate(), sessionTask.getTarget(), sessionTask.getParent(), Status.FINISH);
        if(sessionTasks.isEmpty()) {
            SessionTask parentTask = sessionTaskDao.load(sessionTask.getSession(), sessionTask.getAssessor(), sessionTask.getDelegate(), sessionTask.getTarget(), sessionTask.getParent());
            genericDaoSupport.update(parentTask.status(Status.FINISH));
        }
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.admin.service.SessionDuringService#competencySubmit(com.ihg.hiex.entity.session.during.SessionCalibrationCompetency, java.util.List, java.util.List, java.util.List, com.ihg.hiex.entity.session.task.SessionTask)
     */
    public void competencySubmit(SessionCalibrationCompetency sessionCalibrationCompetency,
            List<SessionCalibrationAnchorScore> anchorScores, List<Long> strong, List<Long> weak, SessionTask sessionTask) {
        
        // update sessionCalibrationCompetency
        genericDaoSupport.update(sessionCalibrationCompetency.changeStatus(SessionCalibrationStatus.FINISH));
        
        for(SessionCalibrationAnchorScore anchorScore : anchorScores) {
            SessionCalibrationAnchorScore oldAnchorScore = genericDaoSupport.load(SessionCalibrationAnchorScore.class, anchorScore.getId());
            boolean isStrong = strong.contains(anchorScore.getId()) ? true : false;
            boolean isWeak = weak.contains(anchorScore.getId()) ? true : false;
            genericDaoSupport.update(oldAnchorScore.score(anchorScore.getScore(), isStrong, isWeak));
        }
        
        // update sessionCalibrationCompetency task
        genericDaoSupport.update(sessionTask.status(Status.FINISH));
        
        // if all tasks had finished then finish meeting task
        Session session = sessionTask.getSession();
        Assessor assessor = sessionTask.getAssessor();
        Delegate delegate = sessionTask.getDelegate();
        // finish competency task
        List<SessionTask> unfinishTasks = sessionTaskDao.list(session, assessor, delegate, Type.ASSESSOR, "Peer Calibration Competency", Status.FINISH);
        if(unfinishTasks.isEmpty()) {
            SessionTask parentTask = sessionTaskDao.load(session, assessor, delegate, Type.ASSESSOR, "Peer Calibration Competency");
            genericDaoSupport.update(parentTask.status(Status.FINISH));
        }
        // finish calibration task
        List<SessionTask> unfinishCalibrationTasks = sessionTaskDao.list(session, assessor, delegate, Type.ASSESSOR, "Peer Calibration", Status.FINISH);
        if(unfinishCalibrationTasks.isEmpty()) {
            SessionTask parentTask = sessionTaskDao.load(session, assessor, delegate, Type.ASSESSOR, "Peer Calibration");
            genericDaoSupport.update(parentTask.status(Status.FINISH));
        }
        
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#editCompetency(java.util.List, java.util.List, java.util.List)
     */
    public void editCompetency(List<SessionCalibrationCompetency> competencies, List<String> names, List<SessionAnchorScoreType> results) {
        
        Map<String, SessionCalibrationCompetency> competenciesMap = CollectionUtils.constructMapValue(competencies, "name");
        for(String name : names) {
            SessionCalibrationCompetency competency = competenciesMap.get(name);
            int index = names.indexOf(name);
            genericDaoSupport.update(competency.edit(results.get(index)));
        }
        
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#recommendationSubmit(com.ihg.hiex.entity.session.during.SessionCalibration, java.util.List)
     */
    public void recommendationSubmit(SessionCalibration sessionCalibration,
            SessionCalibrationRecommendation recommendation, SessionTask sessionTask) {
        // save or update recommendation
        if(recommendation.getId() != null) {
            SessionCalibrationRecommendation original = genericDaoSupport.load(SessionCalibrationRecommendation.class, recommendation.getId());
            genericDaoSupport.update(original.edit(recommendation));
        } else {
            genericDaoSupport.save(recommendation.initilization(sessionCalibration));
        }
        
        // update sessionCalibrationCompetency task
        genericDaoSupport.update(sessionTask.status(Status.FINISH));
        
        // if all tasks had finished then finish meeting task
        Session session = sessionTask.getSession();
        Assessor assessor = sessionTask.getAssessor();
        Delegate delegate = sessionTask.getDelegate();
        // finish peer calibration task
        List<SessionTask> unfinishTasks = sessionTaskDao.list(session, assessor, delegate, Type.ASSESSOR, "Peer Calibration", Status.FINISH);
        if(unfinishTasks.isEmpty()) {
            SessionTask parentTask = sessionTaskDao.load(session, assessor, delegate, Type.ASSESSOR, "Peer Calibration");
            genericDaoSupport.update(parentTask.status(Status.FINISH));
        }
        
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#gmPptUpload(com.ihg.hiex.entity.session.Session, com.ihg.hiex.entity.user.Delegate, java.lang.String)
     */
    public void gmPptUpload(Session session, Delegate delegate, String pptUrl) {
        // load sessionReport
        SessionReport sessionReport = sessionReportDao.load(session, delegate);
        
        if(sessionReport == null) {
            sessionReport = new SessionReport(session, delegate, pptUrl, delegate.getId());
            genericDaoSupport.save(sessionReport);
        } else {
            genericDaoSupport.update(sessionReport.editPpt(pptUrl, delegate.getId()));
        }
        
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#saveInBasketAnswer(com.ihg.hiex.entity.session.during.SessionInBasket, com.ihg.hiex.entity.session.during.SessionInBasketAnswer)
     */
    public void saveInBasketAnswer(SessionInBasket sessionInBasket, SessionInBasketAnswer sessionInBasketAnswer) {
        sessionInBasketAnswer.initilization(sessionInBasket);
        genericDaoSupport.save(sessionInBasketAnswer);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#deleteInBasketAnswer(com.ihg.hiex.entity.session.during.SessionInBasketAnswer)
     */
    public void deleteInBasketAnswer(SessionInBasketAnswer sessionInBasketAnswer) {
        genericDaoSupport.update(sessionInBasketAnswer.delete());
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#submitInBasketAnswer(com.ihg.hiex.entity.session.during.SessionInBasket, java.lang.String)
     */
    public void submitInBasketAnswer(SessionInBasket sessionInBasket, String name) {
        sessionInbasketDao.submitAnswer(SessionInBasketAnswerStatus.FINISH, sessionInBasket, name);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#competencySubmit(com.ihg.hiex.entity.session.during.SessionCalibrationCompetency, java.util.List)
     */
    public void competencySubmit(SessionCalibrationCompetency sessionCalibrationCompetency,
            List<SessionCalibrationAnchorScore> anchorScores, Long strong, Long weak) {
        // update sessionCalibrationCompetency
        genericDaoSupport.update(sessionCalibrationCompetency);
        
        for(SessionCalibrationAnchorScore anchorScore : anchorScores) {
            SessionCalibrationAnchorScore oldAnchorScore = genericDaoSupport.load(SessionCalibrationAnchorScore.class, anchorScore.getId());
            boolean isStrong = anchorScore.getId() == strong ? true : false;
            boolean isWeak = anchorScore.getId() == weak ? true : false;
            genericDaoSupport.update(oldAnchorScore.score(anchorScore.getScore(), isStrong, isWeak));
        }
        
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#commentChoose(com.ihg.hiex.entity.session.during.SessionCalibrationComment, com.ihg.hiex.entity.session.task.SessionTask)
     */
    public void commentChoose(SessionCalibrationComment sessionCalibrationComment, SessionTask sessionTask) {
        genericDaoSupport.update(sessionCalibrationComment);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.assessment.service.session.SessionDuringService#commentSubmit(com.ihg.hiex.entity.session.during.SessionCalibrationComment, java.util.List, java.util.List)
     */
    public void commentSubmit(SessionCalibrationComment sessionCalibrationComment, List<String> chooses, List<String> chooseCommets, SessionTask sessionTask) {
        genericDaoSupport.update(sessionCalibrationComment.edit(chooses, chooseCommets));
        
        // update sessionCalibrationCompetency task
        genericDaoSupport.update(sessionTask.status(Status.FINISH));
        
        // if all tasks had finished then finish meeting task
        Session session = sessionTask.getSession();
        Assessor assessor = sessionTask.getAssessor();
        Delegate delegate = sessionTask.getDelegate();
        // finish peer calibration task
        List<SessionTask> unfinishTasks = sessionTaskDao.list(session, assessor, delegate, Type.ASSESSOR, "Peer Calibration", Status.FINISH);
        if(unfinishTasks.isEmpty()) {
            SessionTask parentTask = sessionTaskDao.load(session, assessor, delegate, Type.ASSESSOR, "Peer Calibration");
            genericDaoSupport.update(parentTask.status(Status.FINISH));
        }
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.admin.service.SessionDuringService#reportSubmit(com.ihg.hiex.entity.session.during.SessionCalibration, com.ihg.hiex.entity.session.task.SessionTask, com.ihg.hiex.admin.entity.security.Login)
     */
    public void reportSubmit(SessionCalibration calibration, SessionTask sessionTask, Login login) {
        
        // update sessionCalibrationCompetency task
        genericDaoSupport.update(sessionTask.status(Status.FINISH));
        
        // if all tasks had finished then finish meeting task
        Session session = sessionTask.getSession();
        Assessor assessor = sessionTask.getAssessor();
        Delegate delegate = sessionTask.getDelegate();
        // finish peer calibration task
        List<SessionTask> unfinishTasks = sessionTaskDao.list(session, assessor, delegate, Type.ASSESSOR, "Peer Calibration", Status.FINISH);
        if(unfinishTasks.isEmpty()) {
            SessionTask parentTask = sessionTaskDao.load(session, assessor, delegate, Type.ASSESSOR, "Peer Calibration");
            genericDaoSupport.update(parentTask.status(Status.FINISH));
        }
        
        // save sessionReportWriting
//        this.createSessionReportWriting(calibration, login);
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.admin.service.session.SessionDuringService#generateAnswerStatus(java.util.List, java.util.Map)
     */
    public Map<Long, Status> generateAnswerStatus(List<Long> delegateIds,
            Map<String, List<SessionInBasketAnswer>> answers) {
        
        Map<Long, Status> result = new HashMap<Long, Status>();
        for(Long id : delegateIds) {
            Status status = Status.FINISH;
            if(MapUtils.isNotEmpty(answers) && org.apache.commons.collections.CollectionUtils.isNotEmpty(answers.get(id.toString()))) {
                for(SessionInBasketAnswer answer : answers.get(id.toString())) {
                    if(!answer.getStatus().isFinish()) {
                        status = Status.NOT_START;
                    }
                }
            } else {
                status = Status.NOT_START;
            }
            
            result.put(id, status);
        }
        return result;
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.admin.service.session.SessionDuringService#editRecommendation(com.ihg.hiex.entity.session.during.SessionCalibration, com.ihg.hiex.entity.session.during.report.SessionReportRecommendation, com.ihg.hiex.admin.entity.security.Login)
     */
    public void editRecommendation(SessionCalibration sessionCalibration,
            SessionReportRecommendation sessionReportRecommendation, Login login) {
        SessionReportWriting reportWriting = sessionReportWritingDao.load(sessionCalibration);
        if(reportWriting == null) {
            this.createSessionReportWriting(sessionCalibration, sessionReportRecommendation, login);
        } else {
            genericDaoSupport.update(reportWriting.editRecommendation(sessionReportRecommendation));
        }
        
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.admin.service.session.SessionDuringService#editComment(com.ihg.hiex.entity.session.during.SessionCalibration, com.ihg.hiex.entity.session.during.report.SessionReportComment, com.ihg.hiex.admin.entity.security.Login)
     */
    public void editComment(SessionCalibration sessionCalibration, SessionReportComment sessionReportComment,
            List<String> chooseComments, Login login) {
        SessionReportWriting reportWriting = sessionReportWritingDao.load(sessionCalibration);
        if(reportWriting == null) {
            this.createSessionReportWriting(sessionCalibration, sessionReportComment, login);
        } else {
            genericDaoSupport.update(reportWriting.editComment(sessionReportComment, chooseComments));
        }
    }
    
    /**
     * 
     * @param sessionCalibration
     * @param login
     */
    private void createSessionReportWriting(SessionCalibration sessionCalibration, SessionReportComment comment, Login login) {
        // list SessionCalibrationCompetency
        List<SessionCalibrationCompetency> sessionCalibrationCompetencies = sessionCalibrationDao.listCompetency(sessionCalibration);
        Map<String, SessionCalibrationCompetency> competencies = CollectionUtils.constructMapValue(sessionCalibrationCompetencies, "name");
        
        // load SessionCalibrationRecommendation
        SessionCalibrationRecommendation sessionCalibrationRecommendation = sessionCalibrationDao.loadRecommendation(sessionCalibration);
        
        // load SessionCalibrationComment
        SessionCalibrationComment sessionCalibrationComment = sessionCalibrationDao.loadComment(sessionCalibration);
        
        // save sessionreportwriting first
        SessionReportWriting sessionReportWriting = new SessionReportWriting(sessionCalibration, competencies, comment, sessionCalibrationComment, sessionCalibrationRecommendation, Role.SUPERVISOR, login.getId());
        genericDaoSupport.save(sessionReportWriting);
        
    }
    
    /**
     * 
     * @param sessionCalibration
     * @param recommendation
     * @param login
     */
    private void createSessionReportWriting(SessionCalibration sessionCalibration, SessionReportRecommendation recommendation, Login login) {
        // list SessionCalibrationCompetency
        List<SessionCalibrationCompetency> sessionCalibrationCompetencies = sessionCalibrationDao.listCompetency(sessionCalibration);
        Map<String, SessionCalibrationCompetency> competencies = CollectionUtils.constructMapValue(sessionCalibrationCompetencies, "name");
        
        // load SessionCalibrationRecommendation
        SessionCalibrationRecommendation sessionCalibrationRecommendation = sessionCalibrationDao.loadRecommendation(sessionCalibration);
        
        // load SessionCalibrationComment
        SessionCalibrationComment sessionCalibrationComment = sessionCalibrationDao.loadComment(sessionCalibration);
        
        // save sessionreportwriting first
        SessionReportWriting sessionReportWriting = new SessionReportWriting(sessionCalibration, competencies, sessionCalibrationComment, recommendation, sessionCalibrationRecommendation, Role.SUPERVISOR, login.getId());
        genericDaoSupport.save(sessionReportWriting);
        
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.admin.service.session.SessionDuringService#reportSubmit(com.ihg.hiex.entity.session.during.report.SessionReportWriting)
     */
    public void supervisorReportSubmit(SessionReportWriting reportWriting) {
        genericDaoSupport.update(reportWriting.changeStatus(SessionCalibrationStatus.EDITING));
    }
    
    /*
     * (non-Javadoc)
     * @see com.ihg.hiex.admin.service.session.SessionDuringService#adminReportSubmit(com.ihg.hiex.entity.session.during.report.SessionReportWriting)
     */
    public void adminReportSubmit(SessionReportWriting reportWriting) {
        genericDaoSupport.update(reportWriting.changeStatus(SessionCalibrationStatus.FINISH));
    }
    
}
